package com.wlyuan.open.scanner.utils.enums.transport;

import com.wlyuan.core.marker.NamedValue;
import com.wlyuan.core.marker.NamedValueMap;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Map;

/**
 * @author lijing
 * @description 运单类型对应关系
 */
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@Getter
public enum TransportTypeEnum implements NamedValue<Integer> {

    /**
     * 发货方运单
     */
    CUSTOMER_WAYBILL(10, 10, "发货方运单"),

    /**
     * 承运方运单
     */
    CARRIERS_WAYBILL(20, 20, "承运方运单"),

    /**
     * 拆单运单
     */
    SPLIT_WAYBILL(21, 21, "拆单运单"),

    /**
     * 拼车运单
     */
    COMBINE_WAYBILL(22, 22, "拼车运单"),

    /**
     * 拆单拼车运单
     */
    SPLIT_COMBINE_WAYBILL(23, 23, "拆单拼车运单"),
    ;

    private final Integer value;
    private final Integer newValue;
    private final String name;

    private static final Map<Integer, TransportTypeEnum> MAP = new NamedValueMap<>(TransportTypeEnum.class);

    public static TransportTypeEnum fromValue(Integer value) {
        return MAP.get(value);
    }

    public static boolean isCustomer(Integer val) {
        return CUSTOMER_WAYBILL.getValue().equals(val);
    }

}
